package com.sara.service.impl;

import com.sara.entity.Employee;
import com.sara.entity.EmployeeExample;
import com.sara.mapper.EmployeeMapper;
import com.sara.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    /**
     * 根据用户电话查找用户对象
     *
     * @param userTel
     * @return 用户对象
     */
    @Override
    public Employee findByEmployeeTel(String userTel) {
        EmployeeExample employeeExample = new EmployeeExample();
        employeeExample.createCriteria().andEmployeeTelEqualTo(userTel);
        List<Employee> employees = employeeMapper.selectByExample(employeeExample);
        Employee employee = null;
        if(employees != null && employees.size() > 0){
            employee = employees.get(0);
        }
        
        return employee;
    }
}
